Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.LayoutBuilder=function(a){Telerik.Web.UI.LayoutBuilder.initializeBase(this,[a]);
this._requireCellId=false;
this._layoutXmlFile="";
this._layoutWidth="";
this._layoutHeight="";
this._idCounter=100;
};
Telerik.Web.UI.LayoutBuilder.prototype={initialize:function(){Telerik.Web.UI.LayoutBuilder.callBaseMethod(this,"initialize");
this.loadClientState();
this.updateClientState();
},get_requireCellId:function(){return this._requireCellId;
},set_requireCellId:function(a){this._requireCellId=a;
},get_layoutXmlFile:function(){return this._layoutXmlFile;
},set_layoutXmlFile:function(a){this._layoutXmlFile=a;
},get_layoutWidth:function(){return this._layoutWidth;
},set_layoutWidth:function(a){this._layoutWidth=a;
var b=this._selectedTable;
if(b){tabel.removeAttribute("width");
tabel.style.width=this._layoutWidth;
}},get_layoutHeight:function(){return this._layoutHeight;
},set_layoutHeight:function(a){this._layoutHeight=a;
var b=this._selectedTable;
if(b){tabel.removeAttribute("height");
tabel.style.height=this._layoutHeight;
}},_getElementAttributesHtml:function(d){var e="";
if(d){var c=d.attributes;
var g=c.length;
for(var a=0;
a<g;
a++){var f=c[a].name;
var b=d.getAttribute(f,2);
if(b&&!((f=="colSpan"||f=="rowSpan")&&b=="1")&&f!="tabIndex"&&f!="contentEditable"&&f!="style"){e+=" "+f.toLowerCase()+'="'+b+'"';
}}var h=d.style.cssText;
if(h){e+=' style="'+h+'"';
}}return e;
},get_serializedTableOuterHtml:function(){if(!this._selectedTable){return"";
}var h="<table ";
h+=this._getElementAttributesHtml(this._selectedTable);
h+=" >";
var c=this._selectedTable.rows;
var d=c.length;
for(var a=0;
a<d;
a++){var g=c[a];
h+="<tr";
h+=this._getElementAttributesHtml(g);
h+=">";
var e=g.cells;
var k=e.length;
for(var b=0;
b<k;
b++){var f=e[b];
h+="<td";
h+=this._getElementAttributesHtml(f);
h+=" >";
h+="<![CDATA["+f.innerHTML+"]]></td>";
}h+="</tr>";
}h+="</table>";
return h;
},_getUniqueCellId:function(){this._idCounter++;
return(this.get_id()+this._idCounter+(new Date()-100));
},_setCellId:function(b){if(!b){return;
}if(this._requireCellId){var a=b.getAttribute("id");
if(!a){a=this._getUniqueCellId();
b.setAttribute("id",a);
}}},_setAllCellsId:function(){if(!this._selectedTable){return;
}var e=this._selectedTable.rows;
var c=e.length;
for(var b=0;
b<c;
b++){var a=e[b].cells;
var f=a.length;
for(var d=0;
d<f;
d++){this._setCellId(a[d]);
}}},loadClientState:function(){var d=$get(this.get_clientStateFieldID());
if(d){var f=d.value;
var a=Sys.Serialization.JavaScriptSerializer.deserialize(f);
if(a.TableHtml){var c=this.decodePostbackContent(a.TableHtml);
c=this.unEscapeNewLines(c);
var b=document.createElement("div");
b.innerHTML=c;
var e=b.firstChild;
if(e&&e.tagName=="TABLE"){this.set_selectedTable(e);
}}}},saveClientState:function(){var b=this.get_serializedTableOuterHtml();
var a={TableHtml:(this._selectedTable)?this.encodePostbackContent(b):""};
return Sys.Serialization.JavaScriptSerializer.serialize(a);
},escapeNewLines:function(b){var a=b.replace(/\n/gi,"&nbsp;<telerikcr />");
a=a.replace(/\r/gi,"<teleriklf />");
return a;
},unEscapeNewLines:function(b){var a=b.replace(/(&nbsp;)?<telerikcr\s*\/>/gi,"\n");
a=a.replace(/<teleriklf\s*\/>/gi,"\r");
return a;
},_encodeSelectedTable:function(a,e){var d=new Array("%","<",">","!",'"',"#","$","&","'","(",")",",",":",";","=","?","[","]","\\","^","`","{","|","}","~","+");
var c=a;
if(e){for(var b=0;
b<d.length;
b++){c=c.replace(new RegExp("\\x"+d[b].charCodeAt(0).toString(16),"ig"),"%"+d[b].charCodeAt(0).toString(16));
}}else{for(var b=d.length-1;
b>=0;
b--){c=c.replace(new RegExp("%"+d[b].charCodeAt(0).toString(16),"ig"),d[b]);
}}return c;
},encodePostbackContent:function(a){return this._encodeSelectedTable(a,true);
},decodePostbackContent:function(a){return this._encodeSelectedTable(a,false);
},_insertCell:function(d,e,a,c){var b=[];
b[0]=d;
b[1]=e;
b[2]=a;
b[3]=c;
var f=Telerik.Web.UI.LayoutBuilder.callBaseMethod(this,"_insertCell",b);
this._setCellId(f);
return f;
},executeCommand:function(a,b){var c=[];
c[0]=a;
c[1]=b;
Telerik.Web.UI.LayoutBuilder.callBaseMethod(this,"executeCommand",c);
this.updateClientState();
},set_selectedTable:function(e){var b=[];
b[0]=e;
Telerik.Web.UI.LayoutBuilder.callBaseMethod(this,"set_selectedTable",b);
if(this._requireCellId){this._setAllCellsId();
}this.updateClientState();
var d=this._selectedTable;
if(d){var c=d.style.width;
if(!c){c=d.getAttribute("width");
}this._layoutWidth=c;
var a=d.style.height;
if(!a){a=d.getAttribute("height");
}this._layoutHeight=a;
}}};
Telerik.Web.UI.LayoutBuilder.registerClass("Telerik.Web.UI.LayoutBuilder",Telerik.Web.UI.LayoutBuilderEngine);
